package com.power.sifa.correction.model;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.plf.common.domain.YesNo;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
*  地图范围坐标实体类
*/

@Entity
@ApiModel(value="地图范围坐标")
@Data
@Table(name="Crc_geopoint",schema="sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Builder
@AllArgsConstructor
//@IdClass(Crc_geopoint.Crc_geopointPK.class) 用于复合组件
public class Crc_geopoint extends BaseModel implements Serializable {

	private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "序号")
    private String id;

    @ApiModelProperty(value = "位置描述")
    private String name;

    @ApiModelProperty(value = "多边形坐标")
    private String geopoints;

    @ApiModelProperty(value = "创建人")
    private String createuserid;

    @ApiModelProperty(value = "创建人名称")
    private String createusername;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createtime;

    @ApiModelProperty(value = "父级id")
    private String parentid;

    @ApiModelProperty(value = "排序")
    @Column(name = "sort", nullable=false,insertable=false,updatable=false, columnDefinition="int not null UNIQUE key auto_increment")
    private Integer sort;

    @ApiModelProperty(value = "层级")
    private Integer level;

    @ApiModelProperty(value = "是否是默认初始化范围")
    private Integer defaultarea = YesNo.NO;

    @ApiModelProperty(value = "区域类型")
    private Integer areatype;

    /**
     *  区域类型文本
     */
    @Transient
    @FieldEnumText(eum="Tp_crc_areatype", valuefield="areatype")
    private String areatype_text;


    /**
     *  区域类型文本
     */
    @Transient
    @FieldEnumText(eum="YesNo", valuefield="defaultarea")
    private String defaultarea_text;



    public Map<String, Object> parseMap() {
        Map<String, Object> map=new HashMap<>();
        map.put("id", this.getId());
        map.put("name", this.getName());
        map.put("geopoints", this.getGeopoints());
        map.put("createuserid", this.getCreateuserid());
        map.put("createusername", this.getCreateusername());
        map.put("createtime", this.getCreatetime());
        map.put("parentid", this.getParentid());
        map.put("sort", this.getSort());
        map.put("level", this.getLevel());
        map.put("defaultarea", this.getDefaultarea());
        map.put("areatype_text", this.areatype_text);
        map.put("areatype", this.getAreatype());
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Crc_geopointPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String)key;

        //Crc_geopointPK pk = (Crc_geopointPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}
